﻿using UnityEngine;
using System.Xml;
using System.Collections;
using System.Collections.Generic;

public static class LevelLoader {

    public static List<List<Vector2>> load(string name)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load("Assets\\Map\\LevelManager\\Levels\\" + name);

        XmlNodeList waveNodes = doc.DocumentElement.SelectNodes("/level/wave");

        List<List<Vector2>> waves = new List<List<Vector2>>();

        foreach (XmlNode waveNode in waveNodes)
        {
            waves.Add(new List<Vector2>());
            foreach (XmlNode enemyNode in waveNode.ChildNodes)
            {
                Vector2 data = new Vector2(float.Parse(enemyNode.Attributes["id"].Value), float.Parse(enemyNode.Attributes["number"].Value));
                waves[waves.Count - 1].Add(data);
            }
        }
        return waves;
    }
}
